<script type="text/javascript">
	

    function ajaxFilterDistrict(city_id)
    {
        $.ajax({
        url: '<?php echo $this->Html->url(array("controller" => "districts", "action" => "ajaxDistrictOption", "admin" => false));?>/'+city_id,        
        success: function( data ) {
            if (console && console.log){
              $("#ResourceinfoDistrictId").html(data);
	      //alert($("#ProductDistrictId").val());
	      //ajaxFilterProject($("#ProductDistrictId").val());
            }
          }
        });
    }
    
    function ajaxFilterCareer(city_id)
    {
        $.ajax({
        url: '<?php echo $this->Html->url(array("controller" => "careers", "action" => "ajaxCareerOption", "admin" => false));?>/'+city_id,        
        success: function( data ) {
            if (console && console.log){
              $("#ResourceinfoCareerId").html(data);
	      //alert($("#ProductDistrictId").val());
	      //ajaxFilterProject($("#ProductDistrictId").val());
            }
          }
        });
    }

</script>


<div style="margin-bottom:20px;">
    
    <form action="<?php echo $this->Html->url(array('action' => 'index')); ?>" method="POST" id="filter_index">
    
    <h4>
	<?php __('Loại giới thiệu'); ?>:
        <select onchange="" name="filter_type_id" id="ResourceinfoTypeId">
            
            <?php foreach($types as $ca ) {
                $selected = "";
                if($ca["ResourceinfoType"]["id"] == $type_id)
                {
                    $selected = 'selected="selected"';
                }
            ?>
                <option value="<?php echo $ca["ResourceinfoType"]["id"] ?>" <?php echo $selected; ?> ><?php echo $ca["ResourceinfoType"]["name"] ?></option>
            <?php } ?>
        </select>
     <br /> <br />
    <?php __('City'); ?>:
        <select onchange="ajaxFilterDistrict(this.value);ajaxFilterCareer(this.value);" name="filter_city_id">
            <option value="all"><?php __('Tỉnh/Thành'); ?></option>
            <?php foreach($cities as $c ) {
                $selected = "";
                if($c["City"]["id"] == $city_id)
                {
                    $selected = 'selected="selected"';
                }
            ?>
                <option value="<?php echo $c["City"]["id"] ?>" <?php echo $selected; ?> ><?php echo $c["City"]["name"] ?></option>
            <?php } ?>
        </select>
        <?php __('Quận/Huyện'); ?>:
        <select onchange="" name="filter_district_id" id="ResourceinfoDistrictId">
            <option value="all">- <?php __('Quận/Huyện'); ?> -</option>
            <?php foreach($districts as $d ) {
                $selected = "";
                if($d["District"]["id"] == $district_id)
                {
                    $selected = 'selected="selected"';
                }
            ?>
                <option value="<?php echo $d["District"]["id"] ?>" <?php echo $selected; ?> ><?php echo $d["District"]["name"] ?></option>
            <?php } ?>
        </select>
        
       <?php __('Ngành nghề'); ?>:
        <select onchange="" name="filter_career_id" id="ResourceinfoCareerId">
            <option value="all">- <?php __('Ngành nghề'); ?> -</option>
            <?php foreach($careers as $ca ) {
                $selected = "";
                if($ca["Career"]["id"] == $career_id)
                {
                    $selected = 'selected="selected"';
                }
            ?>
                <option value="<?php echo $ca["Career"]["id"] ?>" <?php echo $selected; ?> ><?php echo $ca["Career"]["name"] ?></option>
            <?php } ?>
        </select>
	
        

    </h4>
    <input type="submit" value="Tìm kiếm" />
    
    </form>
    
</div>

